package com.llynosy.interview.mapper;

import com.llynosy.interview.po.Tag;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface TagMapper extends Mapper<Tag> {

    /**
     * 根据传入的问题查问题对应标签，但是至多返回三行数据
     *
     * @param problemId
     * @return
     */
    @Select("select t.id,t.name from tb_problem p inner join tb_problem_tag pt on p.id=pt.problemId inner join tb_tag \n" +
            " t on pt.tagId=t.id\n" +
            " where p.id=#{problemId} limit 3")
    public List<Tag> queryTagByProblemId(@Param("problemId")Long problemId);

}
